<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/6/11
 * Time: 16:06
 */

namespace api\modules\v1\controllers;


use common\business\EhrHelper;
use common\consts\Consts;
use common\helpers\DateHelper;
use common\helpers\StringUtil;
use common\models\kingdee\HrPersonPhoto;
use common\models\kingdee\OrgAdmin;
use common\models\kingdee\Person;
use yii\db\Exception;
use yii\db\Query;
use yii\filters\RateLimiter;
use yii\helpers\Url;
use yii\rest\ActiveController;


class SummariesController extends ActiveController
{
    public $modelClass = 'common\models\Employee';

    public function behaviors()
    {
        $behaviors = parent::behaviors();

        $behaviors['rateLimiter'] = [
            'class' => RateLimiter::className(),
            'enableRateLimitHeaders' => true,
        ];

//        是否要验证
//        $behaviors['authenticator'] = [
//            'class' => CompositeAuth::className(),
//            'authMethods' => [
//                /*下面是三种验证access_token方式*/
//                //1.HTTP 基本认证: access token 当作用户名发送，应用在access token可安全存在API使用端的场景，例如，API使用端是运行在一台服务器上的程序。
//                //HttpBasicAuth::className(),
//                //2.OAuth 2: 使用者从认证服务器上获取基于OAuth2协议的access token，然后通过 HTTP Bearer Tokens 发送到API 服务器。
//                //HttpBearerAuth::className(),
//                //3.请求参数: access token 当作API URL请求参数发送，这种方式应主要用于JSONP请求，因为它不能使用HTTP头来发送access token
//                //http://localhost/user/index/index?access-token=123
//                QueryParamAuth::className(),
//            ],
//        ];

//        $behaviors['contentNegotiator']['formats']['text/html'] = Response::FORMAT_JSON;
        return $behaviors;
    }

    public function actions()
    {
        $actions = parent::actions();
        // 禁用""index,delete" 和 "create" 操作
        unset($actions['index'], $actions['delete'], $actions['create']);
        return $actions;
    }

    public function actionPageOne(){
        $totalNum = [
            'total' => 23102,
            'compareToYesterday' => 12,
            'compareToLastWeek' => 87,
            'newEveryday' => 7.33,
        ];
        $gender = [
            [
                'x' => '男',
                'y' => 15000,
            ],
            [
                'x' => '女',
                'y' => 8000,
            ],
        ];
        $qywx = [
            'text' => '31%',
            'rate' => 31,
        ];
        $diploma = [
            [
                'x' => '高中及以下',
                'y' => 4000,
            ],
            [
                'x' => '本科',
                'y' => 10000,
            ],
            [
                'x' => '研究生',
                'y' => 3000,
            ],
            [
                'x' => '博士',
                'y' => 1500,
            ],
        ];
        $finish = [
            'rate' => 68,
        ];
        $leave = [
            [
                'x' => '家庭原因',
                'y' => 23.21,
            ],
            [
                'x' => '薪酬原因',
                'y' => 16.07,
            ],
            [
                'x' => '工作环境',
                'y' => 8.93,
            ],
            [
                'x' => '个人原因',
                'y' => 29,
            ],
        ];
        return [
            'total' => $totalNum,
            'gender' => $gender,
            'diploma' => $diploma,
            'qywx' => $qywx,
            'finish' => $finish,
            'leave' => $leave,
        ];
    }
}